package com.ywm.eduService.controller.front;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ywm.commonUtil.R;
import com.ywm.eduService.entity.EduCourse;
import com.ywm.eduService.entity.EduTeacher;
import com.ywm.eduService.service.EduCourseService;
import com.ywm.eduService.service.EduTeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/eduService/indexFront")
public class IndexFrontController {
    @Autowired
    private EduCourseService courseService;
    @Autowired
    private EduTeacherService teacherService;
    //查询前八条热门课程，查询前四条热门名师
    @GetMapping("index")
    public R index(){
        //查询前八个热门课程
//        QueryWrapper<EduCourse> wrapper = new QueryWrapper<>();
//        wrapper.orderByDesc("id");
//        wrapper.last("limit 8");
//        List<EduCourse> eduList = courseService.list(wrapper);
        List<EduCourse> eduList = courseService.getList();

        //查询前四个名师
//        QueryWrapper<EduTeacher> wrapper2 = new QueryWrapper<>();
//        wrapper2.orderByDesc("id");
//        wrapper2.last("limit 8");
//        List<EduTeacher> teacherList = teacherService.list(wrapper2);
        List<EduTeacher> teacherList = teacherService.teacherList();
        return R.ok().data("eduList",eduList).data("teacherList",teacherList);
    }
}
